import operation.*;

import java.util.Scanner;

public class test {
    public static void Main() {
        while (true) {
            operationList operationlist = new operationList();
            Scanner scanner = new Scanner(System.in);
            int choice = menu();
            System.out.println("请输入字符串-》");
            if (choice == 1) {
                String str = scanner.nextLine();
                Operation operation = operationlist.Operations[choice];
                System.out.println("是否输入切割位置：1-》是 2-》否");
                int bool = scanner.nextInt();
                while (true) {
                    if (bool == 1) {
                        System.out.println("输入切割位置");
                        int index = scanner.nextInt();
                        operation.work(str, index);
                        break;
                    } else if (bool == 2) {
                        System.out.println("随机切割字符串");
                        operation.work(str);
                        break;
                    } else {
                        System.out.println("选择错误 重新选择:");
                    }
                }
            } else if (choice == 2 || choice == 3) {
                String str = scanner.nextLine();
                Operation operation = operationlist.Operations[choice];
                operation.work(str);
            } else if (choice == 4) {
                System.out.println("输入第一个字符串");
                String str1 = scanner.nextLine();
                System.out.println("输入第二个字符串");
                String str2 = scanner.nextLine();
                Operation operation = operationlist.Operations[choice];
                operation.work(str1, str2);
            } else if (choice == 5) {
                String str = scanner.nextLine();
                System.out.println("请输入被替换的字符串");
                String str1 = scanner.nextLine();
                System.out.println("请输入要拿什么字符串替换");
                String str2 = scanner.nextLine();
                Operation operation = operationlist.Operations[choice];
                operation.work(str, str1, str2);
            } else if (choice == 0) {
                Operation operation = operationlist.Operations[choice];
                operation.work();
            } else {
                System.out.println("请输入正确的操作");
            }
        }

    }

    public static int menu() {
        System.out.println("==================================");
        System.out.println("1.切割字符串");
        System.out.println("2.大写转小写");
        System.out.println("3.小写转大写");
        System.out.println("4.字符串拼接");
        System.out.println("5.字符串替换");
        System.out.println("0.退出程序");
        System.out.println("==================================");
        System.out.println("请输入你要执行的操作");
        Scanner scanner = new Scanner(System.in);
        return scanner.nextInt();
    }

    public static void main(String[] args) {
        Main();
    }
}


